package com.cmarquez.rgb;

import android.app.Activity;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.graphics.Rect;
import android.graphics.drawable.PaintDrawable;
import android.os.Bundle;
import android.view.View;
import android.widget.CompoundButton;
import android.widget.CompoundButton.OnCheckedChangeListener;
import android.widget.SeekBar;
import android.widget.ToggleButton;
import android.widget.SeekBar.OnSeekBarChangeListener;

public class AdjustRGB extends Activity implements OnSeekBarChangeListener, OnCheckedChangeListener {
	@Override
	protected void onDestroy() {
		// TODO Auto-generated method stub
		super.onDestroy();
	}


	@Override
	protected void onPause() {
		// TODO Auto-generated method stub
		super.onPause();
	}


	private static final int MAX = 255;
	SeekBar red,green,blue;
	View color;
	ToggleButton audio;


	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.adjustvalues);

		red=(SeekBar) findViewById(R.id.seekBarRed);
		green=(SeekBar) findViewById(R.id.seekBarGreen);
		blue=(SeekBar) findViewById(R.id.seekBarBlue);
		color = (View) findViewById(R.id.colorRectangle);
		audio = (ToggleButton) findViewById(R.id.audio);		

		red.setMax(MAX);
		green.setMax(MAX);
		blue.setMax(MAX);
		audio.setChecked(false);

		red.setProgress(0);
		green.setProgress(0);
		blue.setProgress(0);
		
		
		audio.setOnCheckedChangeListener(this);

		red.setOnSeekBarChangeListener(this);
		green.setOnSeekBarChangeListener(this);
		blue.setOnSeekBarChangeListener(this);
		
		


	}


	@Override
	public void onProgressChanged(SeekBar seekBar, int progress,
			boolean fromUser) {
		//color.setBackgroundColor(Color.rgb(red.getProgress(), green.getProgress(), blue.getProgress()));
		

	}


	@Override
	public void onStartTrackingTouch(SeekBar seekBar) {
		// TODO Auto-generated method stub

	}


	@Override
	public void onStopTrackingTouch(SeekBar seekBar) {
		color.setBackgroundColor(Color.rgb(red.getProgress(), green.getProgress(), blue.getProgress()));

		Arduino.sendColors(red.getProgress(), green.getProgress(), blue.getProgress());
	}


	@Override
	public void onCheckedChanged(CompoundButton arg0, boolean arg1) {
		System.err.println("1"); 
		if(audio.isEnabled())
		{
			System.err.println("disable");
			red.setClickable(false);
		}
		
	}

}
